//
//  BaseViewController.swift
//  XMenSwift
//
//  Created by X-MEN on 2021/12/28.
//

import UIKit

class BaseViewController: UIViewController, SlidingDelegate {
    ///是否拦截侧滑返回
    var isInterceptSliding = false;
    
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        if let nav = self.navigationController as? BaseNavigationController {
            if isInterceptSliding {
                nav.slidingDelegate = self;
            }
        }
    }
    
    override func viewWillDisappear(_ animated: Bool) {
        super.viewWillDisappear(animated)
        if let nav = self.navigationController as? BaseNavigationController {
            if isInterceptSliding {
                nav.slidingDelegate = nil;
            }
        }
    }
    
    func slidingBack() {
        let alertController = UIAlertController(title: "系统提示", message: "您确定要退出吗？", preferredStyle: .alert)
        let cancelAction = UIAlertAction(title: "取消", style: .cancel, handler: nil)
        let okAction = UIAlertAction(title: "确定", style: .default, handler: { action in
            self.navigationController?.popViewController(animated: true)
        })
        
        alertController.addAction(cancelAction)
        alertController.addAction(okAction)
        self.present(alertController, animated: true, completion: nil)
    }
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.view.backgroundColor = .white
        //更改uiview的布局从导航栏开始
        self.edgesForExtendedLayout = []
        self.automaticallyAdjustsScrollViewInsets = false;
        
        // Do any additional setup after loading the view.
    }
    

    
}
